
const workDesk = {
    state: {
        cacheTemp: [],
        tempId: '',//mongo 主键 => 编辑
        isEdit: false,
        backGround: '#F2F6FC',
        homeColor: '#F2F6FC'
    },

    mutations: {
        SET_CACHE_TEMP: (state, temp) => {
            state.cacheTemp = state.cacheTemp.concat(temp)
        },
        UPDATE_CACHE_TEMP: (state, list) => {
            state.cacheTemp = list
        },
        SET_IS_EDIT: (state, bool) => {
            state.isEdit = bool
        },
        SET_TEMP_ID: (state, id) => {
            state.tempId = id
        },
        SET_BACK: (state, back) => {
            state.backGround = back
        },
        SET_HOME_COLOR: (state, color) => {
            state.homeColor = color
        }
    },

    actions: {
        async setCacheTemp({commit}, temp) {
            commit('SET_CACHE_TEMP', temp)
        },
        async updateCacheTemp({commit}, list) {
            commit('UPDATE_CACHE_TEMP', list)
        },
        async setIsEdit({commit}, bool) {//判断是否为编辑状态
            commit('SET_IS_EDIT', bool)
        },
        async setTempId({commit}, id) {
            commit('SET_TEMP_ID', id)
        },
        async setBack({commit}, back) {
            commit('SET_BACK', back)
        },
        async setHomeColor({commit}, color) {
            commit('SET_HOME_COLOR', color)
        }
    }
}

export default workDesk
